using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using SiteManager;
using System.Drawing;

public partial class Admin_Ad_DocMetaContent : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"]!=null)
            {
                if (Request.QueryString["id"].ToString().Length > 0)
                {
                    int dr_id = 0;
                   // try
                    {
                        dr_id = Convert.ToInt32(Request.QueryString["id"].ToString());
                        Manager mgr = new Manager(true,"ConnectionString");
                        SqlParameter[] prm = new SqlParameter[1];
                        prm[0] = new SqlParameter("@dr_id",SqlDbType.Int);
                        prm[0].Value=dr_id;
                        SqlDataReader rdr = mgr.ExecuteQuery("ADDEDIT_DOC_METACONTENT", prm);

                        if (rdr.Read())
                        {
                            lblDoctor.Text = dr_id.ToString();

                            lblDescription.Text = "<b>Dr. " + rdr["FNAME"].ToString()
                                + " " + rdr["MNAME"].ToString() + " " + rdr["LNAME"].ToString() 
                                + "</B><br>" + rdr["ADDRESS1"].ToString() + ", " + rdr["ADDRESS2"].ToString() + ", " +
                                rdr["CITY"].ToString() + ", " + rdr["STATE"].ToString() + ", " 
                                + rdr["ZIPCODE"].ToString() + "<br>Phone: " +
                                rdr["PHONE"].ToString() + "<hr noshade>";

                            txtTitle.Text = rdr["META_TITLE"].ToString();
                            txtKeywords.Text = rdr["META_KEYWORDS"].ToString();
                            txtDescription.Text = rdr["META_DESCRIPTION"].ToString();
                        }
                        
                        rdr.Close();
                        mgr = null;
                    }
                    //catch (Exception ex)
                    {
                   //     lblMsg.Text = ex.Message;
                 //       Response.Redirect("Ad_ManageDoctors.aspx", true);
                    }
                }
            }
            else
            {
                Response.Redirect("Ad_ManageDoctors.aspx", true);
            }
        }
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            Manager mgr = new Manager(true,"ConnectionString");
            SqlParameter[] prm = new SqlParameter[5];
            prm[0] = new SqlParameter("@dr_id", SqlDbType.Int);
            prm[1] = new SqlParameter("@MODE", SqlDbType.Int);
            prm[2] = new SqlParameter("@TITLE", SqlDbType.VarChar, 200);
            prm[3] = new SqlParameter("@KEYWORDS", SqlDbType.VarChar, 500);
            prm[4] = new SqlParameter("@DESCRIPTION", SqlDbType.VarChar, 1000);

            prm[0].Value = Convert.ToInt32(lblDoctor.Text);
            prm[1].Value = 1;
            prm[2].Value = txtTitle.Text;
            prm[3].Value = txtKeywords.Text;
            prm[4].Value = txtDescription.Text;

            mgr.ExecuteUpdate("ADDEDIT_DOC_METACONTENT", prm);

            mgr = null;
            lblMsg.ForeColor = Color.Green;
            lblMsg.Text = "Meta-Content updated.";
            lblMsg.Visible = true;
        }
        catch (Exception ex)
        {
            lblMsg.ForeColor = Color.Red;
            lblMsg.Text = ex.Message;
            lblMsg.Visible = true;
        }

    }
}
